import React from 'react';
import { Descriptions } from 'antd';
import trans from '@/utils/translate';
import format from '@/utils/format';
interface Props {
  title?: string,
  obj: object,
  prefix: string,
}
const { Item } = Descriptions;
const Description: React.FC<Props> = (props) => {
  return (
    <>
      <Descriptions
        title={props.title?trans(props.title):false}
        bordered={true}
        column={{ xxl: 4, xl: 3, lg: 3, md: 2, sm: 1, xs: 1 }}
      >
        {
          props.obj &&
          Object.keys(props.obj).map(i => {
            return (
              <Item key={i} label={trans(`${props.prefix}.${i}`)}>{
                i === 'createdAt' ? format(props.obj[i]) : props.obj[i]
              }</Item>
            )
          })
        }
      </Descriptions>
    </>
  )
}

export default Description;
